package ys.ewp.dto;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import ys.ewp.po.TaskStatus;

public class TaskStatusDto {
	//任务状态ID
	private Integer id;
	//任务状态
	private String title;
	//创建时间
	private Date dateCreated;
	//更新时间
	private Date dateUpdated;
	//删除标记
	private boolean deleted = false;
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Date getDateCreated() {
		return dateCreated;
	}
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	public Date getDateUpdated() {
		return dateUpdated;
	}
	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}
	public boolean isDeleted() {
		return deleted;
	}
	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	/**
	 * 根据任务状态Po获取任务状态Dto
	 * @param taskStatus 任务状态
	 * @return
	 */
	public static TaskStatusDto getDtoByPo(TaskStatus taskStatus){
		TaskStatusDto tsDto = new TaskStatusDto();
		tsDto.setId(taskStatus.getId());
		tsDto.setTitle(taskStatus.getTitle());
		tsDto.setDateCreated(taskStatus.getDateCreated());
		tsDto.setDateUpdated(taskStatus.getDateUpdated());
		tsDto.setDeleted(taskStatus.isDeleted());
		return tsDto;
	}
	/**
	 * 根据任务状态Dto获取任务状态Po
	 * @param tsDto 任务状态Dto
	 * @return
	 */
	public static TaskStatus getPoByDto(TaskStatusDto tsDto){
		TaskStatus ts = new TaskStatus();
		ts.setId(tsDto.getId());
		ts.setTitle(tsDto.getTitle());
		ts.setDateCreated(tsDto.getDateCreated());
		ts.setDateUpdated(tsDto.getDateUpdated());
		ts.setDeleted(tsDto.isDeleted());
		return ts;
	}
	
	/**
	 * 	@功能 根据PO列表获取DTO列表
	 * @param taskList 
	 * @return 
	 */
	public static List<TaskStatusDto> getDtoListByPoList(List<TaskStatus> tsList){
		if(tsList == null || tsList.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskStatusDto> tsDtoList = new ArrayList<TaskStatusDto>();
		for(TaskStatus ts : tsList){
			tsDtoList.add(getDtoByPo(ts));
		}
		return tsDtoList;
	}
	/**
	 * @功能 根据DTO列表获取PO列表
	 * @param taskDtoList
	 * @return
	 */
	public static List<TaskStatus> getPoListByDtoList(List<TaskStatusDto> tsDtoList){
		if(tsDtoList == null || tsDtoList.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskStatus> tsList = new ArrayList<TaskStatus>();
		for(TaskStatusDto taskDto : tsDtoList){
			tsList.add(getPoByDto(taskDto));
		}
		return tsList;
	}
}
